/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package reclamos;

import com.csvreader.CsvReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;

/**
 *
 * @author Balrog
 */
public class LeercsvGestionable {

    public LeercsvGestionable(String ruta) throws IOException{
        try{
        conexion con = new conexion();
        CsvReader Gestionable = new CsvReader(ruta);
        Gestionable.readHeaders();
        String Cd;
        String Descripcion;
        String Responsable;
        String Gestionables;
        String Tipo;
        int contador=0;
        
        while (Gestionable.readRecord()) {
                Cd = Gestionable.get("Cd");
                if (Cd.length() == 0) {
                    Cd = "NULL";
                    contador++;
                }
                Descripcion = Gestionable.get("Descripcion");
                if (Descripcion.length() == 0) {
                    Descripcion = "NULL";
                    contador++;
                }
                 Responsable = Gestionable.get("Responsable");
                if (Responsable.length() == 0) {
                    Responsable = "NULL";
                    contador++;
                }
                 Gestionables = Gestionable.get("Gestionable");
                if (Gestionables.length() == 0) {
                    Gestionables = "NULL";
                    contador++;
                }
                 Tipo = Gestionable.get("Tipo");
                if (Tipo.length() == 0) {
                    Tipo = "NULL";
                    contador++;
                }
                
                con.insertarGestionable(Cd,Descripcion,Responsable,Gestionables,Tipo,contador);
                contador = 0;
            }

            Gestionable.close();
            try {
                con.conexion.close();
            } catch (SQLException ex) {
                Logger.getLogger(Leercsvexpe.class.getName()).log(Level.SEVERE, null, ex);
            }
    }    catch (FileNotFoundException ex) {
            Logger.getLogger(Leercsvexpe.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    
}